<template>
  <div>
    <top-nav from="true" title="登录"></top-nav>
    <form class="login1">
      <div class="con1">
        <img src="/static/img/user/phone.png">
        <input v-model="uname" type="tel" placeholder="请输入手机号">
      </div>
      <div class="con1">
        <img src="/static/img/user/psw.png">
        <input v-model="upass" type="password" placeholder="输入登录密码" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')">
      </div>
    </form>
    <input type="button" value="登录" class="log" @click="login">

    <div class="login2">
      <a href="/register.html" class="reg">免费注册</a>
      <a href="/forget.html" class="for">忘记密码？</a>
    </div>
  </div>
</template>

<script>
  import { base, api, user } from '@/common/constant'
  import vue3des from '@/common/vue-3des'
  import TopNav from '@/components/TopNav'

  export default {
    name: 'login',
    data () {
      return {
        uname: '',
        upass: ''
      }
    },
    methods: {
      login: function () {
        console.log('用户名', this.uname)
        console.log('密码', this.upass)
        this.upass = vue3des.myencode(this.upass)
        console.log('加密后密码', this.upass)
        this.$store.dispatch('post', {
          url: api.login,
          params: {userAccount: this.uname, userPassword: this.upass},
          ok: user.login,
          fail: user.login,
          that: this
        })
      }
    },
    components: {
      TopNav
    }
  }
</script>
